<?php

namespace Content;

/**
 * mysql数据库连接类
 */
class ContentMysqlModel extends \Mysql\MysqlBase {

    /**
     * 表名
     * 
     * @var string
     */
    protected $_tableName = 'content';

    /**
     * 表的主键名
     * 
     * @var string
     */
    protected $_primaryKey = "content_id";

    /**
     * 类实例
     * 
     * @var \Content\ContentMysqlModel
     */
    private static $_instance = null;

    /**
     *
     */
    public function findBySourceHash($sourceHash) {
        $result = $this->fetchAll(null, array('source_hash' => $sourceHash), null, 1);
        if ($result) {
            return $result[0];
        }
        return null;
    }


    /**
     * 获取类实例
     * 
     * @return \Content\ContentMysqlModel
     */
    public static function getInstance() {
        if (!(self::$_instance instanceof self)) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }

}
